package com.day20;

public class Test4 {
    public static void main(String[] args) {
        //创建不规则数组
        int[][] array1={
                {1,2,3},
                {11,22,3,4},
                {12,27,42,42},
                {13,23,45,51},
                {14,21,41,52}
        };

        //遍历数组array1
        System.out.println("遍历不规则数组array1");
        for (int i=0;i<array1.length;i++){
            for (int s=0;s<array1[i].length;s++){
                System.out.print(array1[i][s]+" ");
            }
            System.out.println();
        }

        //创建不规则数组的第二种方式
        System.out.println("遍历不规则数组array2");
        int[][] array2=new int[6][];
        array2[0]=new int[1];
        array2[1]=new int[1];
        array2[2]=new int[2];
        array2[3]=new int[3];
        array2[4]=new int[4];
        array2[5]=new int[5];

        array2[0][0]=11;
        array2[1][0]=2;
        array2[2][1]=1;
        array2[3][2]=1;
        array2[4][3]=1;
        array2[5][4]=1;
        for (int i=0;i<array2.length;i++){
            for (int j=0;j<array2[i].length;j++){
                System.out.print(array2[i][j]+" ");
            }
            System.out.println();
        }
    }
}
